package model.actor;

import java.awt.Color;

import com.egghiro.framework.j2se.game.core.view.canvas.SGraphics;
import com.hiro.framework.tilegame.model.actor.Tile;

public class S2048Tile extends Tile {
    protected int value;
    protected boolean isToRemove;

    protected static final int LABEL_FONT_SIZE = 25;

    public S2048Tile(int i, int j, int value) {
        super(i, j);
        this.value = value;
    }

    @Override
    public void paint(SGraphics graphics) {
        graphics.setColor(Color.BLACK);
        graphics.setFont(LABEL_FONT_SIZE);

        graphics.drawImage(TILE_IMG, getX(), getY());// TODO

        // draw label
        int strX = getX() + this.getWidth() / 2; // save restoreより若干速い
        int strY = getY() + this.getHeight() / 2;
        // anchor : HCENTER
//        strX -= graphics.getFontMetrics().stringWidth(String.valueOf(this.value)) / 2;
//        strY += graphics.getFontMetrics().getAscent() / 2;
//        graphics.drawString(String.valueOf(this.value), strX, strY);
        
        graphics.drawCenterString(String.valueOf(this.value), strX, strY);
    }

    @Override
    protected boolean isToRemove() {
        return this.isToRemove;
    }

}
